<?php
namespace Home\Controller;
use Think\Controller;
/**
 * Class IndexController
 * @package Home\Controller
 * PC页面
 */
class IndexController extends WechatBasicController {

    public function _initialize(){
        parent::_initialize();
        $this -> member = D('Member');
    }

   //首页展示
    public function index(){
    	$where['status'] = array('neq',8);
        $where['nick_name'] = array('neq','');

    	$res = $this -> member -> where( $where ) -> order('utime desc') -> limit(10) -> select();
    	$m_idarr = array();
    	foreach ($res as $key => $obj) {
            $mid['m_id'] = $obj['m_id'];
            $data['utime'] = uniqid();
            $data['status'] = 8;
            $res[$key]['nick_name'] = trim($obj['nick_name']);
            $this -> member -> where( $mid ) -> save($data);
    	}
        
    	if (!empty($_POST['getjson'])) {
    		apiResponse('success','读取成功！',$res);
    	}else{
    		$this -> assign( 'res' , $res );
        	$this->display('index');
    	}
    }


    //
     public function restart(){
    	$where['status'] = array('eq',8);
    	$data['status'] = 0;
    	$res = $this -> member -> where( $where ) -> save($data);
        if (!empty($res)) {
    		apiResponse('success','重置成功！',$res);
    	}else{
    		apiResponse('error','重置失败！');
    	}
    }


}